<?php
    class UserNameCacheCookieStrategy extends NoCacheCookieStrategy
    {
        public function ReviveCookies()
        {
            $userName  = Request::GetCookie("username", "");

            CookieUtils::SetUserNameCookie($userName);
        }

        public function SetLoginCookie(SiteUser $user)
        {
            $this->UpdateUserNameCookie($user);
        }

        public function SetLogoutCookie()
        {
            CookieUtils::SetUserNameCookie("");
        }

        public function UpdateUserNameCookie(SiteUser $user)
        {
            $userName = $user->GetDisplayName();
            if ( $userName )
            {
                CookieUtils::SetUserNameCookie($userName);
            }
        }
    }
